<template>
	<view class="content">
		<image src="@/static/login.jpg" style="width: 100%;"></image>
		<view v-for="(item,index) in list3" :key="index">
			<view class="form-control" v-if="index==ind">
				<u--form labelPosition="left" :model="formData" ref="uForm">
					<view class="input">
						<image src="@/static/user.png"
							style="height: 50rpx; width: 50rpx;margin-left: 30rpx;margin-right: 30rpx;">
						</image>
						<u-form-item borderBottom ref="item1">
							<u--input v-model="item.username" border="none" placeholder="用户名"></u--input>
						</u-form-item>
					</view>
					<view class="input">
						<image src="@/static/phone.jpg"
							style="height: 50rpx; width: 50rpx;margin-left: 30rpx;margin-right: 30rpx;">
						</image>
						<u-form-item borderBottom ref="item1">
							<u--input v-model="item.phone" border="none" placeholder="手机号"></u--input>
						</u-form-item>
					</view>
					<view class="input">
						<image src="@/static/pwd.png"
							style="height: 50rpx; width: 50rpx;margin-left: 30rpx;margin-right: 30rpx;">
						</image>
						<u-form-item borderBottom ref="item1">
							<u--input v-model="item.password" border="none" placeholder="密码" type="password"></u--input>
						</u-form-item>
					</view>
				</u--form>
				<u-radio-group v-model="value" placement="row" @change="groupChange">
					<u-radio v-for="(item, index2) in radiolist1" :key="index2" :label="item.name"
						:name="item.Identity"></u-radio>
				</u-radio-group>
				<view class="bottom">
					<view class="register" @click="goRegister(item)">注册</view>
				</view>
			</view>

			<view class="form-control" v-else-if="index==ind1">
				<u--form labelPosition="left" :model="formData1" ref="uForm">
					<view class="input">
						<image src="@/static/user.png"
							style="height: 50rpx; width: 50rpx;margin-left: 30rpx;margin-right: 30rpx;">
						</image>
						<u-form-item borderBottom ref="item1">
							<u--input v-model="item.username" border="none" placeholder="用户名"></u--input>
						</u-form-item>
					</view>
					<view class="input">
						<image src="@/static/pwd.png"
							style="height: 50rpx; width: 50rpx;margin-left: 30rpx;margin-right: 30rpx;">
						</image>
						<u-form-item borderBottom ref="item1">
							<u--input v-model="item.payword" border="none" placeholder="密码" type="number"
								maxlength='6'></u--input>
						</u-form-item>
					</view>
				</u--form>
				<view class="bottom">
					<view class="register" @click="goPay(item)">设置支付密码</view>
				</view>
			</view>

		</view>

	</view>
</template>

<script>
	import {
		postPerson,
		postPersonPayword
	} from "@/ww.js"
	import {
		toast
	} from "@/common.js"
	export default {
		data() {
			return {
				value: '',
				list3: [{
						username: '',
						password: '',
						phone: ''
					},
					{
						username: '',
						payword: ''
					},
				],
				ind: 0,
				ind1: 2,
				formData: {},
				username: '',
				radiolist1: [{
						name: '用户',
						Identity: 0,
						disabled: false
					},
					{
						name: '商家',
						Identity: 1,
						disabled: false
					}
				],
			}
		},
		methods: {
			goRegister(e) {
				this.list3[1].username = e.username
				postPerson(e).then(res => {
					if (res.code == 200) {
						toast('注册成功')
						this.ind--
						this.ind1--
					}
				})
			},
			goPay(e) {
				if (e.payword.length != 6) {
					toast('请输入6位密码')
				} else {
					postPersonPayword(e).then(res => {
						if (res.code == 200) {
							toast('设置成功')
							setTimeout(() => {
								uni.reLaunch({
									url: '/pages/login/login'
								})
							}, 500)
						}
					})
				}
			},
			groupChange(n) {
				this.list3[0].Identity = n
			},
		}
	}
</script>
<style lang="scss" scoped>
	.content {
		background-color: #fff;
		width: 100%;
		height: 100vh;

		.form-control {
			margin-top: 50rpx;
		}

		/deep/ .uni-forms-item {

			width: 90vw;
			margin-left: 5vw;
			border-bottom: 1rpx solid gainsboro;
			font-size: 30rpx;

			.uni-input {
				display: inline-block;
				width: 80%;
				height: 100%;
				padding-left: 4vw;
			}
		}

		.bottom {
			width: 90vw;
			margin-left: 5vw;
			margin-bottom: 30rpx;

			.register {
				width: 100%;
				margin-top: 40rpx;
				height: 92rpx;
				line-height: 92rpx;
				border-radius: 20rpx;
				text-align: center;
				color: #fff;
				font-size: 32rpx;
				background-color: #359cff;
			}

		}

		.agreeInfo {
			font-size: 24rpx;
			width: 90vw;
			margin-left: 6vw;
		}

		a {
			text-decoration: none;
		}

		::v-deep .uni-checkbox-input {
			width: 30rpx;
			height: 30rpx;
			margin-bottom: 10rpx;
		}
	}

	.input {
		display: flex;
		align-items: center;
	}

	/deep/ .u-form-item__body {
		width: 80vw;
	}

	/deep/ .u-radio-group {
		margin-top: 4vw;
		margin-left: 5vw;
	}

	/deep/ .u-radio {
		margin-right: 3vw;
	}
</style>